main(n,b)
{
	for(gets(&n);~scanf("%d%d",&b,&n);printf("%.lf\n",pow(b,1./n)-0.1));
}
